require 'test/unit'
require 'minitest/spec'
require 'mocha/setup'
require 'tweetabout'

words_hash = TweetAbout::WordsHash[{"of" => 1, "compassion" => 2, "love" => 4, "humanity" => 5,
                                    "together" => 4, "free" => 4}]

describe "#sanitize" do
  it "should remove a useless word" do
    words_hash = words_hash.sanitize
    assert_equal true, !words_hash.has_key?("of")
  end
end

describe "#sort" do
  it "should sort the words" do
    words_hash = words_hash.sort
    values = words_hash.values
    trues = []
    values.each_index do |i|
      val = values[i] >= values[i.next] if values[i.next]
      trues << val if val
    end
    assert_equal false, trues.include?(false)
  end
end